  function [sigma,d1,v1]=drawsigmafast(erdata,v0,s0); 
% function [sigma,d1,v1]=drawsigmafast(erdata,v0,s0); 
% 
% Draws from the posterior of a  Variance 
% distributed as in IG(v0,s0)
% When the prior for B is independent of sigma 
%
% Formulas follow Kim and Nelson (1998)
%
% v0 is the degrees of freedom   
% s0 is the scale parameter 
% Posterior is: 
% sigma^2 ~ IG ([T+ v0 , s0+erdata'erdata )
%
% sigma     sampled variance 
% d1        posterior degrees of freedom 
% v1        posterior scale parameter 
%
% In contrast to drawsigma.m this file treats the degrees of freedom 
% as an integer, rounding downwards and uses the normal to generate
% the values 
% 5/26/04
% ajustiniano@imf.org 
v1= floor( v0 + length(erdata)  );   
s1=( (erdata')*erdata ) +s0; 
nor=randn(v1,1); 
chi=nor'*nor; 
sigma=s1/chi; 
